****************************************
**PAPER: religion and voting behaviour**
**AUTHOR: Piacentini, Molteni, Maraffi**
****************************************


global data //[insert path here]
global cleaned //[insert path here]
global output  //[insert path here]
global wd //[insert path here]



use "$cleaned\ITANES_cleaned", clear


tab tipology, gen(tip_)
tab vote6, gen(voto_)

foreach var of varlist tip_* {
	replace `var' = `var'*100
}

set scheme s1mono

colorpalette  "gs1" "gs15" , ipolate(3) nograph intensity(1.1)
global r1 `r(p1)'
global r2 `r(p2)'
global r3 `r(p3)'

rename voto_1 FDI
rename voto_2 LEGA
rename voto_3 FI 
rename voto_4 AZIONE_IV 
rename voto_5 M5s
rename voto_6 PD

**GRAFICO CON TIPOLOGIA by VOTO**

foreach var of varlist FDI LEGA FI AZIONE_IV M5s PD {

count if `var'==1
local n=r(N)

#delimit ;
graph hbar 	tip_* if `var'==1, stack bar(1,c("$r3"%80) lc(gs2)) bar(2,c("$r2"%80) lc(gs2)) bar(3,c("$r1"%70) lc(gs2)) bar(4,c(gs12%30) lc(gs2)) 
			blabel(bar,pos(center) format(%9.1f) color(gs3)) ylabel(,labcolor(white) noticks) graphregion(margin(20 0 0 0))  
			text(-8 55 "`var'", size(large) placement(center)) text(-8 10 "(n=`n')", placement(center)) 
			legend(order(1 "Practicing Catholic" 2 "Nominal Catholic" 3 "Not religious"))
			legend(row(1) region(col(white))) name(`var', replace) ;
#delimit cr
}

grc1leg FDI LEGA FI AZIONE_IV  M5s PD, legendfrom(FDI) col(1) imargin(25 0 0 0)
graph export "$output\Figure1_R1.png", width(6000) height(4000) replace


**GRAFICO CON VOTO by TIPOLOGIA**


use "$cleaned\ITANES_cleaned", clear

tab tipology, gen(tip_)
tab vote6, gen(voto_)

foreach var of varlist voto_* {
	replace `var' = `var'*100
}

set scheme s1mono

colorpalette  "gs1" "gs15" , ipolate(6) nograph intensity(1.1)
global r1 `r(p1)'
global r2 `r(p2)'
global r3 `r(p3)'
global r4 `r(p4)'
global r5 `r(p5)'
global r6 `r(p6)'


rename tip_1 PRACTICING
rename tip_2 NOMINAL
rename tip_3 NOT_RELIGIOUS 


foreach var of varlist PRACTICING NOMINAL NOT_RELIGIOUS  {

count if `var'==1
local n=r(N)

#delimit ;
graph hbar 	voto_* if `var'==1, stack bar(1,c("$r6"%90) lc(gs2)) bar(2,c("$r5"%90) lc(gs2)) bar(3,c("$r4"%90) lc(gs2)) bar(4,c("$r3"%90) lc(gs2)) bar(5,c("$r2"%90) lc(gs2)) bar(6,c("$r1"%80) lc(gs2)) 
			blabel(bar,pos(center) format(%9.1f) color(gs3)) ylabel(,labcolor(white) noticks) graphregion(margin(20 0 0 0))  
			text(-8 55 "`var'", size(large) placement(center)) text(-8 10 "(n=`n')", placement(center)) 
			legend(order(1 "FDI" 2 "Lega" 3 "FI" 4 "Azione+IV" 5 "M5S" 6 "PD"))
			legend(row(1) region(col(white))) name(`var', replace) ;
#delimit cr
}

grc1leg PRACTICING NOMINAL NOT_RELIGIOUS, legendfrom(PRACTICING) col(1) imargin(25 0 0 0)
graph export "$output\Figure2_R1.png", width(8500) height(4000) replace





